package com.simple.handler.demo003;


/**
 * 网关责任链工厂 设置请求链
 */
public class GetewayHandlerFactory {

    public static GetewayHandler getFirstGetewayHandler(){
        //api接口限流
        GetewayHandler apiLimitGetewayHandler = new ApiLimitGetewayHandler();
        //黑名单拦截
        GetewayHandler blacklistGetwayHandler = new BlacklistGetwayHandler();
        //用户会话拦截
        GetewayHandler sessionGetwayHandler = new SessionGetwayHandler();
        //参数过滤
        GetewayHandler paramGetwayHandler = new ParamGetwayHandler();

        apiLimitGetewayHandler.setNext(blacklistGetwayHandler);//api接口限流的下一步是黑名单拦截
        blacklistGetwayHandler.setNext(sessionGetwayHandler);//杯名单拦截的下一步是用户会话拦截
        sessionGetwayHandler.setNext(paramGetwayHandler);//用户会话拦截的下一步是参数果过滤拦截

        return apiLimitGetewayHandler;
    }
}
